package com.jingsai.Controller;

import com.jingsai.POJO.Common.ScoreHistory;
import com.jingsai.POJO.Common.TodayProblemId;
import com.jingsai.POJO.Common.UserScore;
import com.jingsai.Service.Service;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RequiredArgsConstructor
@RestController
public class Controller {
    private final Service service;
    @GetMapping("/getRanking")
    public ArrayList<UserScore> getRanking() {
        return service.selectUserScore();
    }
    @GetMapping("/getRanking/{userInfo}")
    public List<ScoreHistory> getRanking(@PathVariable("userInfo")String userInfo) {
        return service.selectScoreHistoryBy_user_info(userInfo);
    }
    @PostMapping("/setproblem")
    public String setProblem(@RequestBody TodayProblemId todayProblemId) {
        service.insertProblem(todayProblemId);
        return "ok";
    }
}
